﻿@using RBS.Common @model RBS.Core.Model.Hotel.H_Hotel_Users
@{
    ViewBag.Title = "酒店用户操作";
    Layout = "~/Views/Shared/_Layout.cshtml"; 
}

<!--导航栏-->
@{
    @Html.Partial("_Location");
}
<!--/导航栏-->



<!--内容-->
<div class="content-tab-wrap">
    <div id="floatHead" class="content-tab">
        <div class="content-tab-ul-wrap">
            <ul>
                <li><a href="javascript:;" onclick="tabs(this);" class="selected">酒店用户操作</a></li>
            </ul>
        </div>
    </div>
</div>

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true) 
    @Html.HiddenFor(model => model.Id)
    @Html.HiddenFor(model => model.HotelId)
    @Html.HiddenFor(model => model.regTime)
    <div class="tab-content">
        <dl>
            <dt>用户账户</dt>
            <dd>
                @if (Model.Id > 0)
                {   @Html.DisplayFor(model => model.H_UID, null, new { @class = "input normal", datatype = "m" }) 
                    @Html.HiddenFor(model => model.H_UID)
                }
                else
                {   @Html.TextBoxFor(model => model.H_UID, null, new { @class = "input normal", datatype = "m", ajaxurl = "../tools/hotelAjax.ashx?action=email_validate" }) 
                    <span class="Validform_checktip">*请输入手机号码</span> 
                }


            </dd>
        </dl>
        <dl>
            <dt>用户姓名</dt>
            <dd>
                @Html.TextBoxFor(model => model.H_UserName, null, new { @class = "input normal", datatype = "*2-10" })
                <span class="Validform_checktip">*2-5个字符</span>
            </dd>
        </dl>
        <dl>
            <dt>密码</dt>
            <dd>
                @Html.TextBox("PasswordNew", null, new { @class = "input normal", datatype = "*6-20", nullmsg = "请设置密码", errormsg = "密码范围在6-20位之间", sucmsg = " ", value = ViewBag.defaultpassword })
                @Html.HiddenFor(model => model.Password)
                <span class="Validform_checktip">*密码范围在6-20位之间</span>
            </dd>
        </dl>
        <dl>
            <dt>所属角色</dt>
            <dd>
                <div class="rule-multi-porp">

                    <span id="action_type">
                        @foreach (KeyValuePair<string, string> kvp in Utils.HotelRole())
                        {
                            var b = "";
                            if (ViewBag.roles != null)
                            {
                                foreach (var a in ViewBag.roles)
                                {
                                    if (kvp.Key == a)
                                    {
                                        b = "checked";
                                    }
                                }
                            }
                            <input id="@kvp.Key" type="checkbox" @b name="RoleIds" value="@kvp.Key" datatype="*"  nullmsg="请选择角色！" />
                            <label for="@kvp.Key">@kvp.Value </label>
                        }
                    </span>
                </div>

                <span class="Validform_checktip">*角色ID</span>
            </dd>
        </dl>
          <dl>
            <dt>配菜部门</dt>
            <dd>
               <div class="rule-multi-radio">  
                   <span id="action_type">
                       <label for="Cuisine">不参与配菜</label>
                                   @Html.RadioButtonFor(model => model.DeptId, 0, new { @id = "radio1", @name = "rdolstState" ,datatype="max2", nullmsg="请选择配菜部门！" })  
                       @foreach (var role in new RBS.Core.BLL.Hotel.H_Hotels_Role().GetModelList(" HotelId=" + Model.HotelId))
                       {
                           <label for="Cuisine">@role.RoleName</label>
                           @Html.RadioButtonFor(model => model.DeptId, @role.Id, new { @id = "radio1", @name = "rdolstState" ,datatype="max2", nullmsg="请选择配菜部门！" })  
                       }
                   </span>
                </div> 
              
            </dd>
        </dl>
    </div>
    <!--/内容-->

    <!--工具栏-->
    <div class="page-footer">
        <div class="btn-list">
            <input type="submit" value="提交保存" class="btn" />
            <input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript: history.back(-1);" />

        </div>
        <div class="clear"></div>
    </div>
    <!--/工具栏-->
    
    <script>
        $(function () {
            $.extend($.Datatype, { 
                "max2": function (gets, obj, curform, regxp) {
                    var atmax = 1,
                        numselected = curform.find("input[name='" + obj.attr("name") + "']:checked").length;

                    if (numselected == 0) {
                        return false;
                    } else if (numselected > atmax) {
                        return "最多只能选择" + atmax + "项！";
                    }
                    return true;
                }
            });

           /* $(".registerform").Validform({
                tiptype: 2,
                datatype: {//传入自定义datatype类型【方式二】;
                    "need2": function (gets, obj, curform, regxp) {
                        var need = 2,
                            numselected = curform.find("input[name='" + obj.attr("name") + "']:checked").length;
                        return numselected >= need ? true : "请至少选择" + need + "项！";
                    },

                    "max2": function (gets, obj, curform, regxp) {
                        var atmax = 2,
                            numselected = curform.find("input[name='" + obj.attr("name") + "']:checked").length;

                        if (numselected == 0) {
                            return false;
                        } else if (numselected > atmax) {
                            return "最多只能选择" + atmax + "项！";
                        }
                        return true;
                    }

                }
            });*/
        })

    </script>
        
}










